package org.sundy.net;

import java.io.BufferedInputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

public class Demo {

	public static void main(String[] args) throws Exception {
		URL url = new URL("http://192.168.0.247:9000/api-service-json/fetchData");
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setDoOutput(true);
		conn.setRequestMethod("POST");
		conn.setUseCaches(false);
		conn.setRequestProperty("Content-Type",
				"application/x-www-form-urlencoded");
		// conn.setRequestProperty("Content-Length", String.valueOf(params
		// .length()));
		//conn.setRequestProperty("appId", "CLW-2012-C01");
		//conn.setRequestProperty("appKey", "S2JSU7902WU220DDYUMZ");
		conn.setDoInput(true);
		conn.connect();

		OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(),
				"UTF-8");
		out.write("{CLWID:'6'}");
		out.flush();
		out.close();
		BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
		int len = 0;
		while ((len = bis.read()) > 0) {
			System.out.print((char) len);
		}
		bis.close();
		conn.disconnect();
	}
}
